package cn.wolfcode.luowowo.mgrsite.controller;

import cn.wolfcode.luowowo.article.domain.Destination;
import cn.wolfcode.luowowo.article.domain.Region;
import cn.wolfcode.luowowo.article.service.IDestinationService;
import cn.wolfcode.luowowo.article.service.IRegionService;
import cn.wolfcode.luowowo.common.query.QueryObject;
import cn.wolfcode.luowowo.common.util.JSONResult;
import com.github.pagehelper.PageInfo;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("region")
public class RegionController {
    @Reference
    private IDestinationService destinationService;

    @Reference
    private IRegionService regionService;

    @RequestMapping("list")
   public String list(@ModelAttribute("qo")QueryObject qo,Model model){
        PageInfo<Region> pageInfo = regionService.queryForList(qo);
        model.addAttribute("pageInfo",pageInfo);
        return "region/list";
    }

    @RequestMapping("listDestByRegionId")
    @ResponseBody
    public List<Destination> listDestByRegionId(Long rid){
          List<Destination> listDests  =destinationService.listDestByRegionId(rid);
        return listDests;
    }
    @RequestMapping("listDests")
    @ResponseBody
    public List<Destination> listDests(){
          List<Destination> listDests  =destinationService.selectAll();
        return listDests;
    }


}
